﻿@namespace MudBlazor.Docs.Examples

@inject ISnackbar Snackbar

<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@Show">
    Open snackbar
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@Hide">
    Hide snackbar
</MudButton>

@code {
    private const string Key = "Same";

    void Show()
    {
        var config = (SnackbarOptions options) =>
        {
            options.VisibleStateDuration = int.MaxValue;
            options.DuplicatesBehavior = SnackbarDuplicatesBehavior.Allow;
        };

        Snackbar.Add($"Now click hide snackbar. Key: {Key}", Severity.Normal, config, Key);
        Snackbar.Add($"Now click hide snackbar. Key: {Key}", Severity.Normal, config, Key);
    }

    void Hide()
    {
        Snackbar.RemoveByKey(Key);
    }
}
